<?php
/**
 * XuYuan Project
 *
 * @package	XueYuan 
 * @author	Jiuchi Team
 * @since	Version 1.0.0
 * @filesource
 */
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Login view
 * @author Wayne Yu
 */
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
    <?php $this->load->view('common/head');?>
	<!-- Page special css -->
    <link rel="stylesheet" type="text/css" href="/assets/css/index.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/mycenter.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/mycircle.css">
    <link rel="stylesheet" type="text/css" href="/assets/css/circle_content.css">
    <style>
		.icon-comment{
			margin-left: 48px;
		}
		.i-collect{
		    margin-left: 10px;
			display: inline-block;
		    width: 20px;
		    height: 20px;
		    background-position: -138px -145px;
			background-image: url('../../../assets/images/xy-icon.png');
    		vertical-align: middle;
    		background-repeat: no-repeat;
		}
    </style>
</head>
<body>
    <div class="navigation">
		<?php $this->load->view('common/navigation');?> 
    </div>
    <div class="wrapper">
        <div class="main-content">
			<div class="main-content-inner">
                <div class="cir-profile">
                    <div class="cir-profile-header bd-bottom clearfix">
                        <div class="cir-profile-name fl">
                            <?php echo $circleInfo['name']?>
                        </div>
                        <p class="cir-profile-note fl">
                            <?php echo $circleInfo['description']?>
                        </p>
                        <div class="action fr">
                            <?php echo $conAct;?>
                            <?php echo $joinAct;?>
                        </div>                                
                    </div>
                    <div class="cir-profile-content-wrapper text-small">
                        <div class="cir-profile-content  clearfix">
                            <div class="cir-profile-avatar">
                                <img src="<?php echo $circleInfo['circle_img']?>" class="" style="width:80px">
                            </div>
                        </div>
                        <div class="cir-profile-follow">
                            <a href="#" class="topic-num">
                                <span>话题</span>
                                <br><?php echo $circleInfo['topic_number']?>
                            </a>
                            <a href="<?php echo site_url('circle/viewMember/'.$circleInfo['id'])?>" class="members-mum">
                                <span>成员</span>
                                <br><?php echo $circleInfo['user_number']?>
                            </a>
                        </div>
                    </div>
                </div>
                <div class="home-list">
                    <div id="myCenterTab" class="home-list-title" style="position: relative;">
                        <button class="btn-label active">话题</button>
                        <button class="btn-label" onclick="window.location = '<?php echo site_url('circle/viewMember/'.$circleInfo['id'])?>'">成员</button>
                        <div id="publish-topic" class="btn-blue fancybox fancybox.iframe btn-create-circle" style="cursor:pointer;position: absolute;top:0px;right: 18px;line-height: 1.6;font-weight: normal;">发布话题</div>
                    </div>
                    <div id="myCenterContent">
                        <div id="myDynamic" class="home-list-content clearfix">
                            <div id="ep-tips" class="ep-tips">
                                <span>暂时还没有人发布话题，快去试试发布话题。</span>
                            </div>
                            <ul id="cirTopicsMore">
                                <li class="topic-item">
                                    <div class="rep" style="border-bottom: 1px solid #ccc;">
                                        <div class="rep-header clearfix relative">
                                            <div class="rep-avatar">
                                                <a target="_blank" href="#" class="headportrait"></a>
                                            </div>
                                            <div class="rep-note">
                                                <span class="rep-auth-src name"></span>&nbsp<span class="rep-catalog text-small">发表的话题</span>
                                                <div class="rep-title ellipsis title"></div>
                                            </div>
                                             <div class="btn-cellection btn-blue" onclick="btnCellection()">收藏</div>
                                        </div>
                                        <div class="rep-content-wrapper clearfix" >
                                            <div class="rep-content">
                                                <div class="topicphoto"></div>
                                                <div class="rep-comment content" style="overflow: hidden;max-height:150px;"></div>
                                            </div>
                                        </div>
                                        <div class="rep-footer clearfix">
                                        	<div class="icon-comment fl">
                                        		<i class="iconfont">&#xe64d;</i>
                                        		<span class="num-comment">111</span>
                                        	</div>
                                        	<div class="icon-collect fl">
                                        		<i class="i-collect"></i>
                                        		<span class="num-comment">111</span>
                                        	</div>
                                        	<div class="rep-time fr">1小时前</div>
                                        </div>
                                    </div>
                                </li>
                                <a href="javascript:;" class="btn-white btn-more btn-more-topics">查看更多</a>
                            </ul>
                        </div>

                    </div>            
                </div>
            </div>
        </div>
        <div class="footer">
			<?php $this->load->view('common/footer');?>
        </div>
    </div>

    <!-- Page special scripts -->
    <script type="text/javascript" src="/assets/js/jquery.more.js"></script>
	<script type="text/javascript">
		$(document).ready(function() {
            $('#cirTopicsMore').more({
                'address'   :   '<?php echo site_url('circle/getCircleTopics/'.$circleInfo['id'])?>',
                'template'  :   '.topic-item',
                'trigger'   :   '.btn-more-topics',
                'defaultshow' :'#ep-tips',
            });
            // $('#btn-follow').click(function () {
            // 	$.ajax({
            //         type: 'post',
            //         url: '<?php echo ''?>',
            //         data: {
            //         },
            //         datatype: 'json',
            //         success: function(data) {
            //             if (data.StatusCode == 200) {
                            
            //             } else if (data.StatusCode == 300) {
            //                 return flase;
            //             }
            //         }
            //     });
            //     var btnStaus=$('#btn-follow').text();
            //     if(btnStaus=="立即关注"){
            //         $(this).toggleClass("btn-cellection-cancel").text("已关注");                
            //     }else{
            //         $(this).toggleClass("btn-cellection-cancel").text("立即关注"); 
            //     }     
            // });
        $(".topicphoto img").fancybox({
                'transitonIn' : 'elastic',
                'transitonOut' : 'elastic',
                'speedIn' : 600,
                'speedOut' : 200,
                'overlayShow' :false,
                afterClose : function () {
                    location.reload(true);
                    return;
                }

            })
	    $("#publish-topic").fancybox({
                href:"<?php echo site_url('topic/create/'.$circleInfo['id'])?>",
                minWidth:500,
                minHeight:300,
                padding:5,
            })
		});
    /* 关注圈子 */
        function btnConcern(ele) {
            var ele =$(ele);
            $.ajax({
                type: 'post',
                url: '<?php echo site_url('circle/userAction')?>',
                data: {
                    action : "concern",
                    circle_id : <?php echo $circleInfo['id']?>,           
                },
                dataType: 'json',
                success: function(data) {
                    if (data.StatusCode == 200) {
                        alert("关注成功");
                        var newElement = '<div class="rep-concern fr" onclick="btnUnConcern(this)">取消关注</div>';
                        ele.prop("outerHTML",newElement);
                    } else if (data.StatusCode == 300) {
                        alert(data.Msg);
                    }
                }
            });
        }

/* 取消关注 */ 
        function btnUnConcern(ele) {
            var a=confirm("你确定取消关注么？")
            if(a=true){
                var ele =$(ele);
                $.ajax({
                    type: 'post',
                    url: '<?php echo site_url('circle/userAction/')?>',
                    data: {
                        action : "unconcern",
                        circle_id : <?php echo $circleInfo['id']?>,           
                    },
                    dataType: 'json',
                    success: function(data) {
                        if (data.StatusCode == 200) {
                            alert("取关成功");
                            var eleParent =ele.parent();
                            var newElement = '<div class="rep-concern active fr" onclick="btnConcern(this)">关注圈子</div><div class="rep-concern active fr" onclick="btnJoin(this)">申请加入</div>';
                            eleParent.html(newElement);
                        } else if (data.StatusCode == 300) {
                            alert(data.Msg);
                        }
                    }
                });
            }else{
                return;
            }            
        }

/* 申请加入 */ 
        function btnJoin(ele) {
            var ele =$(ele);
            $.ajax({
                type: 'post',
                url: '<?php echo site_url('circle/userAction/')?>',
                data: {
                    action : "join",
                    circle_id : <?php echo $circleInfo['id']?>,         
                },
                dataType: 'json',
                success: function(data) {
                    if (data.StatusCode == 200) {
                        alert("申请成功，并已经关注。");
                        var eleParent =ele.parent();
                        var newElement = '<div class="rep-concern fr" onclick="btnConcern(this)">取消关注</div><div class="rep-concern fr" onclick="btnWaitCheck(this)">待审核</div>';
                        eleParent.html(newElement);
                    } else if (data.StatusCode == 300) {
                        alert(data.Msg);
                    }
                }
            });
        }

/* 待审核状态 */ 
        function btnWaitCheck(ele) {
            var ele =$(ele);
            alert("你的申请正在审核中，请耐心等待。")
        };
/* 退出圈子 */ 
        function btnQuit(ele) {
            var a=confirm("你确定退出圈子么，同时你也将取消关注。")
            if(a=true){
                var ele =$(ele);
                $.ajax({
                    type: 'post',
                    url: '<?php echo site_url('circle/userAction/')?>',
                    data: {
                        action : "quit",
                        circle_id : <?php echo $circleInfo['id']?>,           
                    },
                    dataType: 'json',
                    success: function(data) {
                        if (data.StatusCode == 200) {
                            alert("退出成功");
                            var newElement='<div class="rep-concern active fr" onclick="btnJoin(this)">申请加入</div>';
                            ele.prop("outerHTML",newElement);
                        } else if (data.StatusCode == 300) {
                            alert(data.Msg);
                        }
                    }
                });    
            }else{
                return;
            }            
        }

        
 /* 收藏 */   
    function btnCellection(ele) {
        var ele =$(ele);
        $.ajax({
            type: 'post',
            url: '<?php echo site_url('')?>',
            data: {
                action : "cellcetion",
                topic_id : <?php echo $circleInfo['topic_number']?>,          
            },
            dataType: 'json',
            success: function(data) {
                if (data.StatusCode == 200) {
                    alert("收藏成功");
                    var newElement='<div class="btn-cellection btn-blue btn-cellection-cancel" onclick="btnUnCellection()">已收藏</div>';
                    ele.prop("outerHTML",newElement);
                } else if (data.StatusCode == 300) {
                    alert(data.Msg);
                }
            }
        });       
    }
 /* 取消收藏 */
    function btnUnCellection(ele) {
        var ele =$(ele);
        $.ajax({
            type: 'post',
            url: '<?php echo site_url('')?>',
            data: {
                action : "uncellcetion",
                topic_id : <?php echo $circleInfo['topic_number']?>,          
            },
            dataType: 'json',
            success: function(data) {
                if (data.StatusCode == 200) {
                    alert("已经取消收藏");
                    var newElement='<div class="btn-cellection btn-blue" onclick="btnCellection()">收藏</div>';
                    ele.prop("outerHTML",newElement);
                } else if (data.StatusCode == 300) {
                    alert(data.Msg);
                }
            }
        });       
    }   
	</script>
</body>
</html>

